﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace word.others
{
    public partial class Progress : Form
    {
        public string message;
        Boolean bol = true;
        public Progress()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_start_Click(object sender, EventArgs e)
        {
            try {
                pro.Maximum = int.Parse(TB_lenth.Text.ToString());
                timer1.Start();
            }
            catch(Exception eq)
            {
                MessageBox.Show("输入错误" + eq.Message,"提示");
            }
            
        }

        private void btn_stop_Click(object sender, EventArgs e)
        {
        
            if (bol)
            {
                printlog("进度条暂停运行");
                timer1.Stop();
                btn_stop.Text = "继续";
            }
            else
            {
                printlog("进度条继续");
                timer1.Start();
                btn_stop.Text = "暂停";
            }
            bol = !bol;

        }

        private void btn_pause_Click(object sender, EventArgs e)
        {
            pro.Value = 0;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (pro.Value < int.Parse(TB_lenth.Text))
            {
                pro.Value += 1;
               
                printlog("\t进度进行中" +double.Parse(pro.Value.ToString())/(int)(pro.Maximum)*100+"%");
            }
        }

        public void printlog(String message)
        {
            TB_log.AppendText(DateTime.Now.ToShortDateString()+ message + "\r\n"+".....");
        }
    }
}
